package net.lab1024.sa.admin.module.users.borrow.controller;

import net.lab1024.sa.admin.module.users.borrow.domain.form.*;
import net.lab1024.sa.admin.module.users.borrow.domain.vo.EquipmentBorrowApplicationVO;
import net.lab1024.sa.admin.module.users.borrow.service.EquipmentBorrowApplicationService;
import net.lab1024.sa.admin.module.users.equipmentmanage.service.EquipmentManageService;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import cn.dev33.satoken.annotation.SaCheckPermission;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 实训室耗材申请 Controller
 *
 * @Author 王俊权
 * @Date 2024-11-08 13:31:04
 * @Copyright 🐂🐎bloc
 */

@RestController
@Tag(name = "实训室耗材申请")
public class EquipmentBorrowApplicationController {

    @Resource
    private EquipmentBorrowApplicationService equipmentBorrowApplicationService;



    @Operation(summary = "分页查询 @author 王俊权")
    @PostMapping("/equipmentBorrowApplication/queryPage")
    @SaCheckPermission("equipmentBorrowApplication:query")
    public ResponseDTO<PageResult<EquipmentBorrowApplicationVO>> queryPage(@RequestBody @Valid EquipmentBorrowApplicationQueryForm queryForm) {
        return ResponseDTO.ok(equipmentBorrowApplicationService.queryPage(queryForm));
    }

    @Operation(summary = "添加 @author 王俊权")
    @PostMapping("/equipmentBorrowApplication/add")
    @SaCheckPermission("equipmentBorrowApplication:add")
    public ResponseDTO<String> add(@RequestBody @Valid EquipmentBorrowApplicationAddForm addForm) {
        return equipmentBorrowApplicationService.add(addForm);
    }

    @Operation(summary = "更新 @author 王俊权")
    @PostMapping("/equipmentBorrowApplication/update")
    @SaCheckPermission("equipmentBorrowApplication:update")
    public ResponseDTO<String> update(@RequestBody @Valid EquipmentBorrowApplicationUpdateForm updateForm) {
        return equipmentBorrowApplicationService.update(updateForm);
    }

    @Operation(summary = "批量删除 @author 王俊权")
    @PostMapping("/equipmentBorrowApplication/batchDelete")
    @SaCheckPermission("equipmentBorrowApplication:delete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Integer> idList) {
        return equipmentBorrowApplicationService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author 王俊权")
    @GetMapping("/equipmentBorrowApplication/delete/{id}")
    @SaCheckPermission("equipmentBorrowApplication:delete")
    public ResponseDTO<String> batchDelete(@PathVariable Integer id) {
        return equipmentBorrowApplicationService.delete(id);
    }

    @Operation(summary = "审批 @author LYY")
    @PostMapping("/equipmentBorrowApplication/approve")
    @SaCheckPermission("equipmentBorrowApplication:approve")
    public ResponseDTO<String> approve(@RequestBody EquipmentBorrowApplicationApprovalForm updateForm) {
        return equipmentBorrowApplicationService.approve(updateForm);
    }

    @Operation(summary = "归还 @author LYY")
    @PostMapping("/equipmentBorrowApplication/return")
    @SaCheckPermission("equipmentBorrowApplication:return")
    public ResponseDTO<String> returnEquipment(@RequestBody EquipmentReturnForm updateForm) {
        return equipmentBorrowApplicationService.returnEq(updateForm);
    }

    @Operation(summary = "归还审核 @author LYY")
    @GetMapping("/equipmentBorrowApplication/returnAdmin/{id}")
    @SaCheckPermission("equipmentBorrowApplication:returnAdmin")
    public ResponseDTO<String> returnEqAdmin(@PathVariable Integer id) {
        return equipmentBorrowApplicationService.returnEqAdmin(id);
    }
}
